/*global nw:true, window */

"use strict";

window.nw = window.nw || {};
nw.module = nw.module || {};

nw.module.M3 = function(sandbox) {
	this._sandbox = sandbox;
    this._mapping = {
        container: "#m3-view-container",
        template: "#m3-view-template",
        goView1: ".js-goView1",
        goView2: ".js-goView2"
    };
    this._rendered = false;
};

nw.module.M3.prototype = {
	init: function(config) {
		this._config = config;
	},
	render: function() {
        if(this._rendered) {
            return this;
        }

        if(this._sandbox.getCurrentViewName() === this._sandbox.views().v3) {
            this._sandbox.render(this._mapping.template, this._mapping.container, {header: 'module #3'});

            this._sandbox.onClick(this._mapping.goView1, this._goView1.bind(this));
            this._sandbox.onClick(this._mapping.goView2, this._goView2.bind(this));
            this._rendered = true;
        }

        return this;
	},
    _goView1: function() {
        this._sandbox.goView(nw.enums.views.v1);
    },
    _goView2: function() {
        this._sandbox.goView(nw.enums.views.v2);
    },
    show: function() {
        this.render();
        this._sandbox.show(this._mapping.container);
    },
    hide: function() {
        this._sandbox.hide(this._mapping.container);
    },
};